<html lang="zh-CN">
<head>
<title>修改密码</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
.kuang{
	position: relative;
	width: 250px;
	height: 43px;
}	
.lookpsw{
	position: absolute;
	top: 1px;
	right: 10px;
	width: 30px;
	height: 30px;
	background-size: 100% 100%;
	cursor: pointer;
}
.lookpsw.hide{
	background-size: 100% 100%;
}

.STYLE6 {
	color: #999999;
	font-size: 12px;
}
a.gray {color:#999999; text-decoration:none}
a.gray:hover {color:#CCCCCC; text-decoration:none}
</style>

<script src="js/spark-md5.min.js"></script>
<script src="js/jquery-3.5.1.min.js"></script>
</head>
<body>
  <table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
    <tr>
      <td width="15%" valign="top" bgcolor="#E1E1E1"><div id='leftpage'></div></td>
      <td width="85%"><table width="100%" border="0" cellpadding="1" cellspacing="0">
	  <tr>
		<td><table align="center" border="0" cellspacing="0" cellpadding="1">
			<tr>	
				<td colspan="2">		   
					<div class="kuang">
					<input type="password" id='psw' placeholder="原登录密码" style="height:43px;width:250px;"> 
					<div class="lookpsw" id='lookpswA'><img src="" id="showImgA" alt="查看"></div>
					</div>
				</td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			</tr>
			<tr>	
				<td colspan="2">		   
					<div class="kuang">
					<input type="password" id='pswnB' placeholder="新登录密码" style="height:43px;width:250px;"> 
					<div class="lookpsw" id='lookpswB'><img src="" id="showImgB" alt="查看"></div>
					</div>
				</td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			</tr>
			<tr>	
				<td colspan="2">		   
					<div class="kuang">
					<input type="password" id='pswnC' placeholder="确认新密码" style="height:43px;width:250px;"> 
					<div class="lookpsw" id='lookpswC'><img src="" id="showImgC" alt="查看"></div>
					</div>
				</td>
			</tr>
			<tr>
			  <td colspan="2">&nbsp;</td>
			</tr>
			<tr>
			  <td colspan="2" align="center"><input type="submit" onClick="confirm()" value="确定" style="height:40px;width:200px;"></td>
			</tr>
		  </table></td>
	  </tr>
	</table></td>
	
	<tr>
		<td bgcolor="#E1E1E1" align="center">
			<div id='totalpage'></div>
		</td>			
		<td height="60" align="center" >
			<div id='footerpage'></div>
		</td>
	</tr>	

    </tr>
  </table>
</body>
<!--
<script src="js/blueimp-md5-2.18.0.js"></script>
<script src="js/jquery-3.5.1.min.js"></script>
-->
<script> 
	function loadScript(c,d){var b=document.createElement("script");b.type="text/javascript";var e=sessionStorage.getItem(c);e?(b.textContent=e,d(b)):fetch(c).then(function(a){return a.text()}).then(function(a){b.textContent=a;sessionStorage.setItem(c,a);d(b);location.reload()})["catch"](function(a){console.error("Error loading the script:",a)})};
	loadScript("tu_0.js", function(script) {document.head.appendChild(script);});
</script>
<script>
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("left.htm", "leftpage"); 	
		loadHtml("total.htm", "totalpage"); 	
		loadHtml("footer.htm", "footerpage"); 	
		
		loadPhoto("img/pswlook.png", "showImgA"); 
		loadPhoto("img/pswlook.png", "showImgB"); 
		loadPhoto("img/pswlook.png", "showImgC"); 
		
		var psw = document.getElementById('psw');
		var onclickA = document.getElementById('lookpswA');
		lookImg(psw, onclickA, "showImgA");			
		
		var pswnB = document.getElementById('pswnB');
		var onclickB = document.getElementById('lookpswB');
		lookImg(pswnB, onclickB, "showImgB");	
		
		var pswnC = document.getElementById('pswnC');
		var onclickC = document.getElementById('lookpswC');
		lookImg(pswnC, onclickC, "showImgC");	
	}
	
	var first = 0;
	function fun(){				
		if(first==0){
			first = 1;
			setTimeout(function(){myTimer("cookie")},0);		//自动发送post指,只有打开页面的时候，才发送一次
		}else {
		}
	}
	setInterval("fun()", 100);			// 周期性调用函数 每隔100毫秒调用一次	
	
	function confirm(){ 
		var psw = document.getElementById("psw").value;
		var pswnB = document.getElementById("pswnB").value;
		var pswnC = document.getElementById("pswnC").value;

		if(psw == "" ){ 
			alert('请填原登录密码');
			return false; 
		} 
		if(pswnB == "" || pswnC == ""){ 
			alert('请输入新密码');
			return false; 
		}
		if(pswnB != pswnC){
			alert('两次输入的密码不一致');
			return false; 
		}
		var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");	// 判断密码是否有中文的条件
		if(reg.test(psw) || reg.test(pswnB) || reg.test(pswnC)){							// 判断密码是否有中文的条件
			alert('密码中不能存在文字');
			return false; 
		}
		myTimer("confirmpsw");	
	}	
	
	function myTimer(type) {
		var xhr = postPhp("index.php");
		xhr.onreadystatechange = function () {		//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if(array_name != null){				
				if(type == "cookie"){
					cookiemyFunction(array_name)		// 返回的信息在html页面显
				}
				if(type == "confirmpsw"){
					confirmFunction(array_name)		// 返回的信息在html页面显
				}
			}	
		}		
			
		if(type == "cookie"){
			txtZip(xhr, "t:ncki");	
		}
		if(type == "confirmpsw"){
			var psw = md5(document.getElementById("psw").value); 
			var pswnB = md5(document.getElementById("pswnB").value);
			txtZip(xhr, "t:ampl&pswa:"+psw+"&pswn:"+pswnB, 1);	
		}
	}
	
	function cookiemyFunction(arr) {	
		if(arr.result == "ok"){				
			document.getElementById("totalSpace").textContent= showSpace(arr.totd, arr.usdd);
		}else{
			alert('请先登录后，再操作！');
			window.location.href="user.htm";
			return false; 
		}
	}
	
	function confirmFunction(arr) {
		switch (arr.result) {
			case "ok":
				alert('修改成功,请重新登录');
				window.location.href = "user.htm";
				break;
			case "pswa":
				alert("原登录密码错误");
				return false;
			case "pswn":
				alert("密码不能有特殊字符");
				return false;
			default:
				alert("其它错误");
				return false;
		}
	}	
	
</script>
</html>
